/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.crm.controller;

import java.io.File;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import queenb.net.entitybean.M650;
import queenb.net.entitybean.N100;
import queenb.web.controller.QueenbController;
import queenb.web.crm.store.CustomerStore;
import queenb.web.crm.store.K400Store;
import queenb.web.crm.store.V030Store;
import queenb.web.store.EmployeeStore;
import queenb.web.store.M650Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ResourcesProvider;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.poi.hssf.model.ConvertAnchor;
import queenb.net.entitybean.M020;
import queenb.net.entitybean.V050;
import queenb.net.entitybean.V500;
import queenb.web.store.V050Store;
import queenb.web.store.V500Store;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionName;

/**
 *
 * @author VANANH
 */
public class V030controller extends QueenbController {

    private int PV030;
    private List<N100> listV030Room = new ArrayList<N100>();
    private List<N100> listV030Check = new ArrayList<N100>();
    private List<N100> listV030CheckLP = new ArrayList<N100>();
    public List<N100> list = new ArrayList<N100>();
    private List<N100> listV030hk = new ArrayList<N100>();
    public List<N100> listSelected = new ArrayList<N100>();// Lít chọn nhom nguoi
    public List<N100> listSelectedNDD = new ArrayList<N100>();
    public List<N100> listsearch = new ArrayList<N100>();
    private List<N100> listsearchDD = new ArrayList<N100>();
    private List<N100> listremove = new ArrayList<N100>();
    private List<N100> list4Tour = new ArrayList<N100>();// danh sach update theo tOUR
    private String keysearch = "Nhập từ khóa";
    private List<SelectItem> combV050 = new ArrayList<SelectItem>();
    private List<SelectItem> combV030New = new ArrayList<SelectItem>();
    private List<SelectItem> combV050ForTour = new ArrayList<SelectItem>();
    private int FV050;
    private int flag = 1;
    private double vn033;
    private int pn100;
    private String vv031;
    private int beginContructor;
    private int vn034;
    private int vn035;
    private String status;
    private Boolean check = false;
    private int tip;// khi insert xong moi load lại trang
    private String empString;//kiem tra acion redirect ve trang khi dong popupup sms
    private int pm575;
    private int tipTour;// phân biệt id khi change combobox
    private List<N100> lstExportExcel = new ArrayList<N100>();
    private Workbook wb = new HSSFWorkbook();
    private int currentRow = 0;
    private String vv036;
    private int pnsoft;// searchtheo Room
    private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    // add 
    private String VV038;// ticket
    private String VV039;// loai xe
    private String VV040;// loai phong
    private String VV041;// noi khoi hanh
    private String VV042;// chuyen bay
    private String VV043;// hang hang khong
    private String VV044;// visa
    private String VV045;// gio bay
    private String VV046;// gio bay
    private Date DV047;// gio bay
    private Date DV048;// gio bay
    private String VV038T;// ticket
    private String VV039T;// loai xe
    private String VV040T;// loai phong
    private String VV041T;// noi khoi hanh
    private String VV042T;// chuyen bay
    private String VV043T;// hang hang khong
    private String VV044T;// visa
    private String VV045T;// gio bay
    private String VV046T;// gio bay
    private Date DV047T;// gio bay
    private Date DV048T;// gio bay
    private String VV061;// ten nhom
    private int VN062;// id nhóm
    private String tabString = "TABNTG";// chon tab trong Tour
    private int idSearch;
    private String keySearch;
    private int FN100;// nguoi
    private String listpersonalforTour;// danh sach nguoi theo tour can bo sung thong tin
    public List<N100> listSelectedHK = new ArrayList<N100>();// dnah sahc d chcon add vao hangkhong
    private int vnn035;// so nguoi
    private int vnn036;// loai phong
    private int vnn037;// so phong
    private String tourname;
    private String tourcode;
    private List<N100> listVisa;
    private int flagAcviteVisa;
    private String active;
     private List<N100> listpersonalDD = new ArrayList<N100>();// danh sach nguoid ai diẹn
    private boolean checkndd;// check nguoi dai dien
    private boolean checkngt;// check nguoi gio thieu
    private int numberphong = 0;
    private List<V050> listngayTour;
    private List<N100> listallphong = new ArrayList<N100>();
    private int tongsonguoi;
    private int tongsophongDK;
    private int tongsonguoiCP;
    private int tongsonguoiKP;
    private long longdate;
    private Date ngaybatdau = null ;
    private Date ngayketthuc = null;
    private Date tongsongay = null;
    private List<Integer> listngay= new ArrayList<Integer>();
    //  private List<M020> listoftabM020 = new ArrayList<M020>();

    public V030controller() throws SQLException, InstantiationException, ParseException {
        //listSelected.clear();

        getKapiMenu().setAdmin(false);
        getKapiMenu().setMainmenu1("m15"); // Hien thi Menu nao dc chon

        Object objempString = getRequest().getParameter("redirect");
        if (objempString != null) {
            this.empString = objempString.toString();
        }

        try {
            Object objempSort = getRequest().getParameter("pnsort");
            if (objempSort != null) {
                this.pnsoft = Util.parseInt(objempSort);
            }
        } catch (Exception e) {
        }
        // link tu project qua du an tour
        Object actionpro = getRequest().getParameter("actionpro");
        if (actionpro != null) {
            if (actionpro.equals("choosevisa")) {
                setTabString("TABVISA");
                SessionProvider.setSessionMapValue("TABNTG", tabString);
            }
            Object objempcode = getRequest().getParameter("codetour");
            if (objempcode != null) {
                SessionProvider.setSessionMapValue(SessionName.TOUR_CODE, objempcode);
            }

//            Object objempnametour = getRequest().getParameter("nametour");
//            if (objempnametour != null) {
//                SessionProvider.setSessionMapValue(SessionName.TOUR_NAME, objempnametour);
//            }
//
//            Object objempdatetour = getRequest().getParameter("datetour");
//            if (objempdatetour != null) {
//                SessionProvider.setSessionMapValue(SessionName.TOUR_DATE, objempdatetour);
//            }
//
//            Object objempunicodetour = getRequest().getParameter("unicodetour");
//            if (objempunicodetour != null) {
//                SessionProvider.setSessionMapValue(SessionName.TOUR_NAME_UNI, objempunicodetour);
//            }

            Object objempnametourid = getRequest().getParameter("pv050");
            if (objempnametourid != null) {
                SessionProvider.setSessionMapValue("codetourselect", objempnametourid);
                V050Store v050Store = new V050Store();
                try {
                    List<V050> listitemV050 = v050Store.vcurpks_listoftabv050new(getLogin().getModule(), getLogin().getCompanyNo(), Util.parseInt(objempnametourid), 0, 0, null, null, null, 0, 50, 0, 0, getLogin().getUserName());
                    if (listitemV050 != null) {
                        for (int i = 0; i < listitemV050.size(); i++) {
                            if (listitemV050.get(i).getFv050() == Util.parseInt(objempnametourid)) {
                                String nameTour = listitemV050.get(i).getVv067();
                                String dateTour = listitemV050.get(i).getVd073().toString();
                                String namtourr = listitemV050.get(i).getVv052();
                                if (nameTour != null) {
                                    SessionProvider.setSessionMapValue(SessionName.TOUR_NAME_UNI, nameTour);
                                }
                                if (namtourr != null) {
                                    SessionProvider.setSessionMapValue(SessionName.TOUR_NAME, namtourr);
                                }
                                if (dateTour != null) {
                                    SessionProvider.setSessionMapValue(SessionName.TOUR_DATE, dateTour);
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                }

            }
        }

        //Kiem tra de redirec ve trang Chiet Tinh hay Danh sach tour
        Object objstatus = getRequest().getParameter("status");
        if (objstatus != null) {
            if (objstatus.toString().trim().equals("T")) {
//                if (SessionProvider.getSessionMapValue("IDVISA") != null) {
//                    SessionProvider.removeSessionMapValue("IDVISA");
//                }
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                if (SessionProvider.getSessionMapValue("listV030") != null) {
                    SessionProvider.removeSessionMapValue("listV030");
                }

                status = "T";
                SessionProvider.setSessionMapValue("status", status);
            } else if (objstatus.toString().trim().equals("C")) {
                if (SessionProvider.getSessionMapValue("IDVISA") != null) {
                    SessionProvider.removeSessionMapValue("IDVISA");
                }

                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                if (SessionProvider.getSessionMapValue("listV030") != null) {
                    SessionProvider.removeSessionMapValue("listV030");
                }
                status = "C";
                SessionProvider.setSessionMapValue("status", status);
            }
        }


        Object pv050 = getRequest().getParameter("pv050");
        if (pv050 != null) {
            FV050 = Integer.parseInt(pv050.toString());
            SessionProvider.setSessionMapValue("codetourselect", FV050);

        }
        Object objTourName = getRequest().getParameter("tourname");
        if (objTourName != null) {
            tourname = objTourName.toString();
            SessionProvider.setSessionMapValue(SessionName.TOUR_NAME, tourname);
        }
        Object objTourcode = getRequest().getParameter("codetour");
        if (objTourcode != null) {
            tourcode = objTourcode.toString();
            SessionProvider.setSessionMapValue(SessionName.TOUR_CODE, objTourcode);
        }
        Object objTourdate = getRequest().getParameter("date");
        if (objTourdate != null) {
            SessionProvider.setSessionMapValue(SessionName.TOUR_DATE, objTourdate);
        }

        Object nametourunnicode = getRequest().getParameter("nametourunnicode");
        if (nametourunnicode != null) {
            SessionProvider.setSessionMapValue(SessionName.TOUR_NAME_UNI, nametourunnicode);
        }

        Object objpm575 = getRequest().getParameter("pm575M");
        if (objpm575 != null) {
            try {
                pm575 = Integer.parseInt(objpm575.toString());
                SessionProvider.setSessionMapValue("pm575M", pm575);
            } catch (Exception e) {
            }

        }

        Object oflag = getRequest().getParameter("flag");
        if (oflag != null) {
            flag = Integer.parseInt(oflag.toString());

        }
        Object objPn100 = getRequest().getParameter("pn100");
        if (objPn100 != null) {
            this.pn100 = Integer.parseInt(objPn100.toString());
        }
//        if ( SessionProvider.getSessionMapValue("listSelected")!= null) {
//           listSelected = (List<N100>) SessionProvider.getSessionMapValue("listSelected");
//        }

        //sendmail Duy
        //  Object listselect = SessionProvider.getSessionMapValue("listSelected");

        Object listselect = SessionProvider.getSessionMapValue(getKapiMenu().getListSelectedEx());
        if (listselect == null) {
            SessionProvider.setSessionMapValue("listSelected", listSelected);
            SessionProvider.setSessionMapValue(getKapiMenu().getListSelectedEx(), listSelected);
            SessionProvider.setSessionMapValue("listSelectedHK", listSelectedHK);
        } else {
            try {
                listSelected = (List<N100>) listselect;
            } catch (Exception e) {
                listSelected = new ArrayList<N100>();
            }
        }
        Object listBean = SessionProvider.getSessionMapValue("listV030");
        if (listBean == null) {
            SessionProvider.setSessionMapValue("listV030", list);
        } else {
            try {
                list = (List<N100>) listBean;
            } catch (Exception e) {
                list = new ArrayList<N100>();
            }
        }
        Object listBeanHK = SessionProvider.getSessionMapValue("listV030HK");
        if (listBeanHK == null) {
            SessionProvider.setSessionMapValue("listV030HK", listV030hk);
        } else {
            try {
                listV030hk = (List<N100>) listBeanHK;
            } catch (Exception e) {
                listV030hk = new ArrayList<N100>();
            }
        }


        Object objAction = getRequest().getParameter("action");
         System.out.println("----------Action-------------"+objAction);
        if (objAction != null) {
            if (objAction.equals("getlistV180")) {
                if (SessionProvider.getSessionMapValue("selected") != null) {
                    SessionProvider.removeSessionMapValue("selected");
                }
            } else if (objAction.equals("getlistforRoom")) {
                if (SessionProvider.getSessionMapValue("selected") != null) {
                    SessionProvider.removeSessionMapValue("selected");
                }
            }else if (objAction.equals("getPrint")) {
                Object pn100Obj = getRequest().getParameter("pt950");
                if (pn100Obj != null) {
                    SessionProvider.setSessionMapValue(SessionName.PT950NEWKEY, pn100Obj);
                   System.out.println("------------------PT950-------"+pn100Obj);
                }
            }else if(objAction.equals("checkpersonalDD")){
                 Object pn100Obj = getRequest().getParameter("pn100");
                if (pn100Obj != null) {
                    pn100 = Util.parseInt(pn100Obj);
                }
                Object FV050Obj = getRequest().getParameter("fv050");
                if (FV050Obj != null) {
                    FV050 = Util.parseInt(FV050Obj);
                }
                Object FV050Obj1 = getRequest().getParameter("vn062");
                if (FV050Obj1 != null) {
                    VN062 = Util.parseInt(FV050Obj1);
                }
                 Object FV050Obj12 = getRequest().getParameter("vv061");
                if (FV050Obj12 != null) {
                    VV061 = FV050Obj12.toString();
                }
                if(pn100!=0&&FV050!=0){
                    updatepersonaldd(pn100,FV050,VN062,VV061);
                }
            }else if (objAction.equals("deleteV030Room")) {

                Object objPV050 = getRequest().getParameter("fn100");
                if (objPV050 != null) {
                    pn100 = Util.parseInt(objPV050);
                }

                SessionProvider.setSessionMapValue("IDDELETEFN100TOUR", pn100);
            } else if (objAction.equals("addpersonalforTour")) {
                Object objPV050 = getRequest().getParameter("pv050");
                if (objPV050 != null) {
                    FV050 = Util.parseInt(objPV050);
                }

                Object listforTour = SessionProvider.getSessionMapValue("listSelected");


                if (listforTour != null) {
                    try {
                        list4Tour = (List<N100>) listforTour;
                        System.out.println("------DANH SACH NGUOI THEO TOUR- khi add--" + list4Tour.size());
                        if (list4Tour.size() > 0) {
                            for (int i = 0; i < list4Tour.size(); i++) {
                                N100 cus = list4Tour.get(i);

                                // MailItem mail = new MailItem(cus.pn100, cus.getHoten(), cus.getNv105(), "", cus.getPronouns(), "");
                                //  listMail.add(mail);
                                listpersonalforTour += list4Tour.get(i).getHoten() + ";  ";
                                System.out.println("------ho ten nhưng nguoi bi add--" + listpersonalforTour);

                            }
                        }
                    } catch (Exception e) {
                        list4Tour = new ArrayList<N100>();
                    }
                } else {
                    list4Tour = new ArrayList<N100>();
                }


                //listKH = V030controller.listSelected;
                SessionProvider.setSessionMapValue("cus4tour", 1);
            } else if (objAction.equals("addticket")) {
                Object objectFV050 = getRequest().getParameter("pv050");
                Object pn100AA = getRequest().getParameter("pn100");
                if (objectFV050 != null) {
                    FV050 = Util.parseInt(objectFV050);
                }

                if (pn100AA != null) {
                    pn100 = Util.parseInt(pn100AA);
                }
                Object objectFV0501 = getRequest().getParameter("vn033");
                Object pn100AA1 = getRequest().getParameter("vv031");

                if (objectFV0501 != null) {
                    vn033 = Double.valueOf(objectFV0501.toString());
                }

                if (pn100AA1 != null) {
                    vv031 = pn100AA1.toString();
                }
                getListByIDV030(FV050, pn100);
            } else if (objAction.equals("saveprice")) {
                // Object objPn100 = getRequest().getParameter("pn100");
                Object objVN033 = getRequest().getParameter("vn033");
                if (objPn100 != null) {

                    this.vn033 = Double.valueOf(objVN033.toString());
                    updateColumn();

                }
            } else if (objAction.equals("showlistfortour")) {
                Object objFV050 = getRequest().getParameter("fv050");
                if (objFV050 != null) {
                    FV050 = Util.parseInt(objFV050);
                    SessionProvider.setSessionMapValue("IDIDIDFV050", FV050);
                    System.out.println("-------------------SETOUR--------" + SessionProvider.getSessionMapValue("IDIDIDFV050"));
                }
                Object objFV150 = getRequest().getParameter("fv150");
                if (objFV150 != null) {

                    SessionProvider.setSessionMapValue("IDIDIDFV150", objFV150);
                    System.out.println("------------FV150-------SETOUR--------" + SessionProvider.getSessionMapValue("IDIDIDFV150"));
                }
            } else if (objAction.equals("deleteV030")) {
                Object objV030 = getRequest().getParameter("idV030");
                if (objV030 != null) {
                    pn100 = Util.parseInt(objV030);
                    SessionProvider.setSessionMapValue("IDDELETEV030", pn100);
                }
                Object objV050 = getRequest().getParameter("idV050");
                if (objV050 != null) {

                    FV050 = Util.parseInt(objV050);

                }
                System.out.println("--------CONG NGHE MOI-----------" + pn100 + FV050);
            } else if (objAction.equals("activeV030")) {
                Object objV050 = getRequest().getParameter("idV050");
                if (objV050 != null) {

                    FV050 = Util.parseInt(objV050);

                }
                System.out.println("-------ACTIVE-----------" + FV050);
            } else if (objAction.equals("delSS")) {
                if (SessionProvider.getSessionMapValue("IDVISA") != null) {
                    SessionProvider.removeSessionMapValue("IDVISA");
                }
                if (SessionProvider.getSessionMapValue("selected") != null) {
                    SessionProvider.removeSessionMapValue("selected");
                }
                if (SessionProvider.getSessionMapValue("listSelected") != null) {
                    SessionProvider.removeSessionMapValue("listSelected");
                }
                if (SessionProvider.getSessionMapValue("listSelectedHK") != null) {
                    SessionProvider.removeSessionMapValue("listSelectedHK");
                }
            } else if (objAction.equals("searchforVISA")) {
                // Object objPn100 = getRequest().getParameter("pn100");
                Object objID = getRequest().getParameter("idSearch");
                Object objKEY = getRequest().getParameter("keySearch");
                if (objID != null) {

                    this.idSearch = Util.parseInt(objID);
                    SessionProvider.setSessionMapValue("IDVISA", idSearch);
                }
                if (objKEY != null) {

                    this.keySearch = objKEY.toString();
                    SessionProvider.setSessionMapValue("KEYVISA", keySearch);
                }
            } else if (objAction.equals("selectVISA")) {
                // Object objPn100 = getRequest().getParameter("pn100");
                Object ID = getRequest().getParameter("id");
                if (ID != null) {
                    this.FV050 = Util.parseInt(ID);
                }
            } else if (objAction.equals("editpersonalDAIDIEN")) {
                Object objectFV050 = getRequest().getParameter("pv050");
                if (objectFV050 != null) {
                    FV050 = Util.parseInt(objectFV050);
                }
                Object objectFN100DD = getRequest().getParameter("pn100DD");
                if (objectFN100DD != null) {
                    // PV0303 lay tam de thay cho nguoi theo tour
                    PV030 = Util.parseInt(objectFN100DD);
                }

                //   System.out.println("sssssssssssssssss----------------------" + FV050 + "=======PVVVVVVVV========" + PV030);
            } else if (objAction.equals("addCusp100HK")) {
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");
                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {
                    for (int i = 0; i < listV030hk.size(); i++) {
                        if (listV030hk.get(i).pn100 == Integer.parseInt(f.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(listV030hk.get(i));
                            break;
                        }
                    }
                }
                SessionProvider.setSessionMapValue("listSelectedHK", listSelected);
                SessionProvider.setSessionMapValue("listV030HK", listV030hk);

                System.out.println("LÍT HANG KHONG----" + f + "....." + listSelected.size());
            } else if (objAction.equals("addCusp100PO")) {
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");
                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).pn100 == Integer.parseInt(f.toString())) {
//                            if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(list.get(i));
                            break;
                        }
                    }
                }
                SessionProvider.setSessionMapValue("listSelectedHK", listSelected);
                SessionProvider.setSessionMapValue("listV030", list);
            } else if (objAction.equals("addCusp100")) {
                Object f = getRequest().getParameter("p100");
                Object s = getRequest().getParameter("valueC");
                if ("false".equals(s.toString())) {
                    for (int i = 0; i < listSelected.size(); i++) {
                        if (listSelected.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.remove(i);
                            break;
                        }
                    }
                } else {

                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).pn100 == Integer.parseInt(f.toString())) {
                            listSelected.add(list.get(i));
                            break;
                        }
                    }
                }
                List<N100> listgetrros = (List<N100>) listSelected;
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelected", listSelected);
                SessionProvider.setSessionMapValue("listV030", list);
            } else if (objAction.equals("addAllCusp100")) {
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelected.clear();
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelected.add(list.get(i));
                        } else {
                            listSelected.add(list.get(i));
                        }
                    }
                } else {
                    listSelected.clear();
                }
                List<N100> listgetrros = (List<N100>) listSelected;
                SessionProvider.setSessionMapValue("NUMBERPER", listgetrros.size());
                SessionProvider.setSessionMapValue("listSelected", listSelected);
                SessionProvider.setSessionMapValue("listV030", list);
            } else if (objAction.equals("addAllCusp100HK")) {
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelectedHK.clear();
                    for (int i = 0; i < listV030hk.size(); i++) {
                        if (listV030hk.get(i).getNv105() != null && listV030hk.get(i).getNv105() != "" && listV030hk.get(i).getNv105().contains("@")) {
                            listSelectedHK.add(listV030hk.get(i));
                        } else {
                            listSelectedHK.add(listV030hk.get(i));
                        }
                    }
                } else {
                    listSelectedHK.clear();
                }

                SessionProvider.setSessionMapValue("listSelectedHK", listSelectedHK);
                SessionProvider.setSessionMapValue("listV030HK", listV030hk);
            } else if (objAction.equals("addAllCusp100PO")) {
                Object va = getRequest().getParameter("boool");
                if ("true".equals(va.toString())) {
                    listSelectedHK.clear();
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getNv105() != null && list.get(i).getNv105() != "" && list.get(i).getNv105().contains("@")) {
                            listSelectedHK.add(list.get(i));
                        } else {
                            listSelectedHK.add(list.get(i));
                        }
                    }
                } else {
                    listSelectedHK.clear();
                }

                SessionProvider.setSessionMapValue("listSelectedHK", listSelectedHK);
                System.out.println("---------LIst NAY NHIUE----------" + listSelectedHK.size());
                SessionProvider.setSessionMapValue("listV030", list);
            } else if (objAction.equals("updateV030")) {

                Object objV031 = getRequest().getParameter("vv031");
                if (objV031 != null) {
                    this.vv031 = objV031.toString();
                }
                saveV030();

            } else if (objAction.equals("addEmp")) {

                Object objV031 = getRequest().getParameter("step12");
                if (objV031 != null) {
                    flag = Util.parseInt(objV031);
                }
                 Object objV0311 = getRequest().getParameter("nn117");
                if (objV0311 != null) {
                   SessionProvider.setSessionMapValue("choisetabchoisetab", objV0311);
                }
                Object objFN100P = getRequest().getParameter("pn100P");
                if (objFN100P != null) {
                    pn100 = Util.parseInt(objFN100P);
                }

            } else if (objAction.equals("updatechecknn")) {
                Object objVn034 = getRequest().getParameter("vn034");
                if (objVn034 != null) {
                    this.vn034 = Integer.parseInt(objVn034.toString());
                    CustomerStore store = new CustomerStore();
                    store.updateColumnINT(null, "V030", "VN034", vn034, "FN100", pn100, getLogin().getUserName());
                }
            } else if (objAction.equals("updatecheckct")) {

                Object objVn035 = getRequest().getParameter("vn035");
                if (objVn035 != null) {
                    this.vn035 = Integer.parseInt(objVn035.toString());
                    CustomerStore store = new CustomerStore();

                    store.updateColumnINT(null, "V030", "VN035", vn035, "FN100", pn100, getLogin().getUserName());
                }
            } else if (objAction.equals("clear")) {
                listSelected.clear();
                SessionProvider.setSessionMapValue("listSelected", null);

            } else if (objAction.equals("checkTourDD")) {
                Object objectPn100dd = getRequest().getParameter("pn100");
                Object objectFk100DD = getRequest().getParameter("fk100");
                if (objectPn100dd != null && objectFk100DD != null) {
                    pn100 = Util.parseInt(objectPn100dd);
                    FV050 = Util.parseInt(objectFk100DD);
                    System.out.println("----------- themnguoi  vao vcong ty " + pn100 + FV050);
                    updatePersonalDD(pn100, FV050);
                }



            } else if (objAction.equals("checkTourPP")) {
                Object objectPn100dd = getRequest().getParameter("pn100");
                Object objectFk100DD = getRequest().getParameter("fk100");
                if (objectPn100dd != null && objectFk100DD != null) {
                    pn100 = Util.parseInt(objectPn100dd);
                    FV050 = Util.parseInt(objectFk100DD);
                    System.out.println("----------- themnguoi  vao vcong ty " + pn100 + FV050);
                    updatePersonalPP(pn100, FV050);
                }



            } else if (objAction.equals("checkTour")) {
                Object objectPn100dd = getRequest().getParameter("FV050TTT");
                if (objectPn100dd != null) {
                    SessionProvider.setSessionMapValue("codetourselectID", Util.parseInt(objectPn100dd));
                    System.out.println("----ID TOUR----" + SessionProvider.getSessionMapValue("codetourselectID"));
                }
                if (objPn100 != null) {
                    pn100 = Util.parseInt(objPn100);
                    System.out.println("----ID CHEK00----" + pn100);
                    saveSelected(pn100);
                }


            } else if (objAction.equals("checkpesonalforTour")) {
                Object idFv050 = getRequest().getParameter("FV050");
                Object idPN100 = getRequest().getParameter("PN100");
                Object idPN100E = getRequest().getParameter("PN100E");
                if (idFv050 != null && idPN100 != null) {
                    pn100 = Util.parseInt(idPN100);
                    FV050 = Util.parseInt(idFv050);
                    PV030 = Util.parseInt(idPN100E);
                    updatePersonalForTour(PV030, FV050, pn100);
                }

            } else if (objAction.equals("checkpesonalforTourTT")) {
                Object idFv050 = getRequest().getParameter("FV050");
                Object idVV036 = getRequest().getParameter("VV036");
                Object idTour = getRequest().getParameter("PN100");
                if (idFv050 != null && idVV036 != null) {
                    vv036 = idVV036.toString();
                    FV050 = Util.parseInt(idFv050);
                    pn100 = Util.parseInt(idTour);
                    updateStatusForTour(FV050, pn100, vv036);
                    //  System.out.println("--------AAAAAAAAAA-------cccccccccc--" + FV050 + "-----" + pn100 + "--" + vv036);
                }

            } else if (objAction.equals("updateroom")) {
                Object idFv0501 = getRequest().getParameter("fn050");
                Object idVV0361 = getRequest().getParameter("room");
                Object idTour1 = getRequest().getParameter("fn100");
                if (idFv0501 != null && idVV0361 != null) {
                    vv036 = idVV0361.toString();
                    FV050 = Util.parseInt(idFv0501);
                    pn100 = Util.parseInt(idTour1);
                    updateRoomForTour(FV050, pn100, vv036);
                    System.out.println("--------AAAAAAAAAA-------cccccccccc--" + FV050 + "-----" + pn100 + "--" + vv036);
                }
            } else if (objAction.equals("chooseTourrTour")) {
                Object idFv0501 = getRequest().getParameter("FV050");

                if (idFv0501 != null) {

                    FV050 = Util.parseInt(idFv0501);

                    System.out.println("-------KH IHCON TOURR--" + FV050);
                }
            }    
            else if (objAction.equals("updateCusRoom")) {
                Object objVN035 = getRequest().getParameter("vn035");
                Object objFn100 = getRequest().getParameter("pn100");
                Object objFV050 = getRequest().getParameter("fv050");
                Object objVV037 = getRequest().getParameter("vv037");
                if (objVN035 != null) {
                    vn035 = Integer.parseInt(objVN035.toString());
                }
                Object objVV036 = getRequest().getParameter("vv036");
                if (objVV036 != null) {
                    vv036 = objVV036.toString(); 
//                    int sp = 0;
//                    int lpvv036 = 0;
//                    if(vv036.toString() !=""){
//                        try {
//                        V030Store v030Store = new V030Store();
//                        System.out.println("CALL list v030 theo so phong : " + Integer.parseInt(objFV050.toString())+","
//                                +vv036+","
//                                +getLogin().getUserName());
//                        
//                            listV030CheckLP = v030Store.VCURPKS_LISTOFTABV030V(Integer.parseInt(objFV050.toString()),vv036,getLogin().getUserName());
//                            if(listV030CheckLP != null && listV030CheckLP.size() > 0){
//                                for (int i = 0; i < listV030CheckLP.size(); i++) {
//                                    if(listV030Check.get(i).getVv037() == null && listV030Check.get(i).getVv036() == null){
//                                        if(vv036.equals(listV030Check.get(i).getVv037()) && objVV037.toString() == listV030CheckLP.get(i).getVv037()){
//                                            setBeginContructor(0);
//                                        }else if(objVV037.toString() == listV030CheckLP.get(i).getVv037() && vv036 != listV030Check.get(i).getVv036()){
//                                            setBeginContructor(1);
//                                            return;
//                                        }else if(objVV037.toString() != listV030CheckLP.get(i).getVv037() && vv036 != listV030Check.get(i).getVv036()){
//                                            setBeginContructor(0);
//                                        }
//                                    }
//                                    
//                                }
//                                
//                            }
//                        } catch (IllegalAccessException ex) {
//                            Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
//                        }
//                    }
                }
               
                boolean checkphong = true;
                if (objVV037.toString().trim() != "") {
                    VV038 = objVV037.toString();  
                    int sp = 0;
                    int lp = 0;
                    if(VV038.toString() !=""){
                        try {
                        V030Store v030Store = new V030Store();
                        System.out.println("CALL list v030 theo so phong : " + Integer.parseInt(objFV050.toString())+","
                                +VV038+","
                                +getLogin().getUserName());
                        
                            listV030Check = v030Store.VCURPKS_LISTOFTABV030V(Integer.parseInt(objFV050.toString()),VV038,getLogin().getUserName());
                            if(listV030Check != null && listV030Check.size() > 0){
                                for (int i = 0; i < listV030Check.size(); i++) {
                                    if(VV038.toString().trim().equals(listV030Check.get(i).getVv037())){
                                        sp +=1;
                                        lp = Integer.parseInt(listV030Check.get(i).getVv036());
                                    }
                                }
                                System.out.println("SP--------------------:" + sp);
                                System.out.println("LP--------------------:" + lp);
                                if(sp == lp){
                                    setBeginContructor(1);
                                    checkphong = false;
                                    return;
                                }else{
                                    setBeginContructor(0);
                                }
                            }
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                }
                if(checkphong == true){
                    if (objFn100 != null && objFV050 != null) {
                        updateOneCol4Room(vn035, vv036, VV038, objFn100.toString(), objFV050.toString());
                    }
                }
                




            }else if(objAction.equals("checksophong")){
                Object objcheckvv037 = getRequest().getParameter("vv037");
                Object objcheckfv050 = getRequest().getParameter("fv050");
                String rqv037;
                V030Store v030Store = new V030Store();
                int sp = 0;
                int lp = 0;
                if(objcheckvv037.toString() !=""){
                    try {
                        rqv037 = objcheckvv037.toString();
                        System.out.println("CALL list v030 theo so phong : " + Integer.parseInt(objcheckfv050.toString())+","
                                +rqv037+","
                                +getLogin().getUserName());
                        listV030Check = v030Store.VCURPKS_LISTOFTABV030V(Integer.parseInt(objcheckfv050.toString()),rqv037,getLogin().getUserName());
                        if(listV030Check != null && listV030Check.size() > 0){
                            for (int i = 0; i < listV030Check.size(); i++) {
                                if(rqv037.toString().trim().equals(listV030Check.get(i).getVv037())){
                                    sp +=1;
                                    lp = Integer.parseInt(listV030Check.get(i).getVv036());
                                }
                            }
                            System.out.println("SP--------------------:" + sp);
                            System.out.println("LP--------------------:" + lp);
                            if(sp == lp){
                              setBeginContructor(1);
                            }else{
                              setBeginContructor(0);
                            }
                        }
                    } catch (IllegalAccessException ex) {
                        Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }

        getKapiMenu().setAdmin(false);
        //  getKapiMenu().setMainmenu1("m152");
    }

    private void updateOneCol4Room(int vnn035, String vv036, String VV037, String fn100, String fv050) {
        try {
            V030Store v030Store = new V030Store();
//            -- VN035: so nguoi
//   -- VV036: loai phong
//   -- VV037: so phong

            System.out.println("-----THAM SO PHOng OC=----" + "Integer.parseInt(fv050)" + Integer.parseInt(fv050) + "," + Integer.parseInt(fn100) + "," + vnn035 + "," + vv036 + "," + vv036 + "," + VV038 + "," + getLogin().getUserName());
            int count = v030Store.stdv_tools_updatetabv030roo(Integer.parseInt(fv050), Integer.parseInt(fn100), vnn035, vv036, VV037, getLogin().getUserName());


            System.out.println("-------------COUNT PHONG OC--------" + count);
        } catch (Exception e) {
        }

    }
    //HUy nguoi so phong

    public void deleteV030Room() {
        try {
            V030Store store = new V030Store();
            System.out.println("--THAM SO XAO ROOO----" + getFV050() + "," + Util.parseInt(SessionProvider.getSessionMapValue("IDDELETEFN100TOUR")) + "," + getLogin().getUserName());
            int count = store.stdv_tools_stornotabv030roo(getFV050(), Util.parseInt(SessionProvider.getSessionMapValue("IDDELETEFN100TOUR")), getLogin().getUserName());
            System.out.println("----------xOA NGUOI--" + count + FV050);
        } catch (Exception e) {
        }
    }

    public void deleteV030() {
        try {
            V030Store store = new V030Store();
            int count = store.deleteV030(FV050, Util.parseInt(SessionProvider.getSessionMapValue("IDDELETEV030")), getLogin().getUserName());
            System.out.println("----------xOA NGUOI--" + count + FV050);
        } catch (Exception e) {
        }
    }
    // acti ve

    public void activeV030() {
        try {
            V030Store store = new V030Store();
            int count = store.stdv_tools_activatabv030visa(getLogin().getModule(), getLogin().getCompanyNo(), FV050, getLogin().getUserName());
            sendRedirect("customer4tour.jsp?status=T&pv050=" + FV050 + "&");
            System.out.println("---------ACtive--" + count + FV050);
        } catch (Exception e) {
        }
    }
    // update Room cho nguoi di tuor

    public void updateRoomForTour(int pn100DD, int tour, String status) {
        try {
            CustomerStore store = new CustomerStore();
            System.out.println("--------AAAAAAAAAA-bbbbbb------cccccccccc--" + FV050 + "-----" + pn100 + "--" + status);
            int count = store.update2ColumnTAB(null, "V030", "VV037", status, "FN100", tour, "FV050", pn100DD, getLogin().getUserName());
            // int count1 = store.updateColumnN100(null, "N100", "NN117", String.valueOf(0), "PN100",pn100DD, getLogin().getUserName());

            System.out.println("---------------cccccccccc--" + count);
        } catch (Exception e) {
        }
    }
    // update trang thai cho nguoi di tuor

    public void updateStatusForTour(int pn100DD, int tour, String status) {
        try {
            CustomerStore store = new CustomerStore();
            System.out.println("--------AAAAAAAAAA-bbbbbb------cccccccccc--" + FV050 + "-----" + pn100 + "--" + vv036);
            int count = store.update2ColumnTAB(null, "V030", "VV036", status, "FN100", pn100DD, "FV050", tour, getLogin().getUserName());
            // int count1 = store.updateColumnN100(null, "N100", "NN117", String.valueOf(0), "PN100",pn100DD, getLogin().getUserName());
            if (count != 0) {
                //sendRedirect("customer4tour.jsp?status=T&pv050="+pn100T);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                // sendRedirect("customer4tour.jsp?status=T&pv050="+pn100T);
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
        } catch (Exception e) {
        }
    }

    public void updatePersonalPP(int pn100DD, int fk100DD) {
        try {
            CustomerStore store = new CustomerStore();
            int count = store.updateColumnN100(null, "N100", "FK100", String.valueOf(fk100DD), "PN100", pn100DD, getLogin().getUserName());
               int count1 = store.updateColumnN100(null, "N100", "NN117", String.valueOf(0), "PN100", pn100DD, getLogin().getUserName());
               System.out.println("------------------------AAAAAAAA"+count+count1);
        } catch (Exception e) {
        }
    }

    public void updatePersonalDD(int pn100DD, int fk100DD) {
        try {
            CustomerStore store = new CustomerStore();
            int count = store.updateColumnN100(null, "N100", "FK100", String.valueOf(fk100DD), "PN100", pn100DD, getLogin().getUserName());
            if( SessionProvider.getSessionMapValue("choisetabchoisetab")!=null){
                  int count1 = store.updateColumnN100(null, "N100", "NN117", SessionProvider.getSessionMapValue("choisetabchoisetab").toString(), "PN100", pn100DD, getLogin().getUserName());
            }
          
        } catch (Exception e) {
        }
    }

    public void updatePersonalForTour(int pn100C, int pn100T, int pn100E) {
        try {
            CustomerStore store = new CustomerStore();
            int count = store.update2ColumnTAB(null, "V030", "FN100C", String.valueOf(pn100C), "FV050", pn100T, "FN100", pn100E, getLogin().getUserName());
            if (count != 0) {
                //sendRedirect("customer4tour.jsp?status=T&pv050="+pn100T);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                // sendRedirect("customer4tour.jsp?status=T&pv050="+pn100T);
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }

        } catch (Exception e) {
        }
    }

    public void updateCheckBox() {
        String p200 = getRequest().getParameter("pn100");

    }

    public void updateColumn() {
        V030Store v300Store = new V030Store();
        System.out.println("-------------update column---" + null + "," + "V030" + "," + "VN033" + "," + this.getVn033() + "," + "FN100" + "," + pn100 + "," + getLogin().getUserName());
        try {
            v300Store.updateColumnV030(null, "V030", "VN033", this.vn033, "FN100", pn100, getLogin().getUserName());
            sendRedirect("customer4tour.jsp?pv050=" + FV050 + "&linkv300=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } catch (Exception ex) {
            sendRedirect("customer4tour.jsp?pv050=" + FV050 + "&linkv300=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

    }

    public void excel() {
        System.out.println("---excel+++++++++++++" + FV050);
    }

    public void changeGroup(ActionEvent ac) {
        if (SessionProvider.getSessionMapValue("IDVISA") != null) {
            SessionProvider.removeSessionMapValue("IDVISA");
        }
        System.out.println("--------------FV050------" + FV050);
        SessionProvider.setSessionMapValue("codetourselect", FV050);
        SessionProvider.setSessionMapValue("listSelected", null);
        SessionProvider.setSessionMapValue("listV030", null);
        listSelected.clear();
        sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050 + "&action=delSS");
    }

    public void reload() {
    }

    public void save() {
        //  System.out.println("---change+++++++++++++" + QV401 + QV402 + FQ300 +"----"+ PQ400);

        K400Store store = new K400Store();
        try {
            //  store.updateK400(PK400, KV401, KV402, getLogin().getModule(), getLogin().getCompanyNo(), getLogin().getUserName());
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } catch (Exception ex) {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("customer.jsp");
    }

    // tim kiem
    public void reloadSearch() {
        try {
            System.out.println("---change+++++++++++++" + idSearch + keySearch);
            if (idSearch != 0) {
                SessionProvider.setSessionMapValue("IDSEARCHV030V", idSearch);
            }

            if (keySearch != null) {
                SessionProvider.setSessionMapValue("IDSEARCHV030V1", keySearch);
            }
        } catch (Exception e) {
        }
    }

    //  ham lay danh sahc
    public List<N100> getListByIDV030(int fv050F, int pn100F) {

        V030Store store = new V030Store();
        try {
            // System.out.println("---tttttttttttttttttttttttttttt+++++++++++++" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + FV050 + "," + 0 + "," + getLogin().getUserName());
            list = store.listV030(getLogin().getModule(), getLogin().getCompanyNo(), fv050F, pn100F, pnsoft, getLogin().getUserName());
            if (list.size() > 0) {
                Iterator icIterator = list.iterator();
                while (icIterator.hasNext()) {
                    N100 v030 = (N100) icIterator.next();
                    pn100 = v030.getPn100();
                    FV050 = v030.getFv050();
                    vv031 = v030.getVv031();

                    // vn033 = Double.valueOf(v030.getVn033());
                    VV038 = v030.getVv038();
                    VV039 = v030.getVv039();
                    VV040 = v030.getVv040();
                    VV041 = v030.getVv041();
                    VV042 = v030.getVv042();
                    VV043 = v030.getVv043();
                    VV044 = v030.getVv044();
                    VV045 = v030.getVv045();
                    VV046 = v030.getVv046();
                    DV047 = v030.getVd047();
                    DV048 = v030.getVd048();

                    VV038T = v030.getVv049();
                    VV039T = v030.getVv050();
                    VV040T = v030.getVv051F();
                    VV041T = v030.getVv052F();
                    VV042T = v030.getVv053();
                    VV043T = v030.getVv054();
                    VV044T = v030.getVv055();
                    VV045T = v030.getVv056();
                    VV046T = v030.getVv057();
                    DV047T = v030.getVd059();
                    DV048T = v030.getVd060();
                }
            }

        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
        }
        SessionProvider.setSessionMapValue("listV030", list);
        System.out.println("D:- dang sach khach hang theo tour: " + list.size());
        return list;
    }

    public void saveV030() throws SQLException, InstantiationException, ParseException {
        try {
            System.out.println("-------------ABC");
            String date = ContextUtil.getRequestParameter("leavedate1");
            if (!date.equals("")) {
                setDV047(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV047(null);
            }

            date = ContextUtil.getRequestParameter("leavedate2");
            if (!date.equals("")) {
                setDV048(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV048(null);
            }
            date = ContextUtil.getRequestParameter("leavedate3");
            if (!date.equals("")) {
                setDV047T(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV047T(null);
            }

            date = ContextUtil.getRequestParameter("leavedate4");
            if (!date.equals("")) {
                setDV048T(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV048T(null);
            }
            System.out.println("--update --v030---------------------------" + FV050 + pn100 + vn033 + vv031);
            V030Store store = new V030Store();

            int count = store.updateV030(FV050, pn100, vv031, null, this.getVn033(), VV038, VV039, VV040, VV041, VV042, VV043, VV044, VV045, VV046, Util.toSQLDate(DV047), Util.toSQLDate(DV048),
                    VV038T, VV039T, VV040T, VV041T, VV042T, VV043T, VV044T, VV045T, VV046T, Util.toSQLDate(DV047T), Util.toSQLDate(DV048T), VV061, VN062, getLogin().getUserName());
            if (count != 0) {
                setTip(count);
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);

                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
            System.out.println("--update ---------------------------" + count + tip);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // update cho nhieu nguoi

    public void updateV030forV100() throws SQLException, InstantiationException, InstantiationException {
        try {
            V030Store store = new V030Store();
            int count = 0;
            Object listforTour = SessionProvider.getSessionMapValue("listSelected");
            if (listforTour != null) {
                list4Tour = (List<N100>) listforTour;
            }

            Object listforTour1 = SessionProvider.getSessionMapValue("LISTV100TOUR");
            List<N100> listforV100 = new ArrayList<N100>();
            if (listforTour1 != null) {
                listforV100 = (List<N100>) listforTour1;
                if (listforV100 != null || listforV100.size() > 0) {
                    DV047 = listforV100.get(0).getVd112();
                    DV048 = listforV100.get(0).getVd113();
                    DV047T = listforV100.get(0).getVd123();
                    DV048T = listforV100.get(0).getVd124();
                    VV045 = listforV100.get(0).getVv105();
                    VV046 = listforV100.get(0).getVv106();
                    System.out.println("----------VV046-----------" + VV046 + listforV100.get(0).getVv106());
                    VV045T = listforV100.get(0).getVv116();
                    VV046T = listforV100.get(0).getVv117();
                    VV040 = listforV100.get(0).getVv109();
                    VV040T = listforV100.get(0).getVv120();
                    VV039 = listforV100.get(0).getVv110();
                    VV039T = listforV100.get(0).getVv121();
                    VV044 = listforV100.get(0).getVv111();
                    VV044T = listforV100.get(0).getVv122();
                    VV042 = listforV100.get(0).getVv107();
                    VV042T = listforV100.get(0).getVv118();
                    VV043 = listforV100.get(0).getVv108();
                    VV044T = listforV100.get(0).getVv119();
                    VV038 = listforV100.get(0).getVv104();
                    VV038T = listforV100.get(0).getVv115();
                    VV041 = listforV100.get(0).getVv103();
                    VV041T = listforV100.get(0).getVv114();

                    VV061 = listforV100.get(0).getLabel();
                    VN062 = listforV100.get(0).getVal();
                }
            }

            System.out.println("--LIST---------V100-------" + listforV100.size());
            if (list4Tour.size() > 0) {
                for (int i = 0; i < list4Tour.size(); i++) {
                    // N100 cus = listKH.get(i);
                    count = store.updateV030(FV050, list4Tour.get(i).getPn100(), vv031, null, this.getVn033(), VV038, VV039, VV040, VV041, VV042, VV043, VV044, VV045, VV046, Util.toSQLDate(DV047), Util.toSQLDate(DV048),
                            VV038T, VV039T, VV040T, VV041T, VV042T, VV043T, VV044T, VV045T, VV046T, Util.toSQLDate(DV047T), Util.toSQLDate(DV048T), VV061, VN062, getLogin().getUserName());
                    System.out.println("---------- CHUYEN nay xay ra bao nhiue alnf----" + VV041);

                }
            }

            if (count != 0) {
                setTip(count);
                listSelected.clear();
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);

                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
            System.out.println("--update ---------------------------" + count + tip);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void saveV030ForTour() throws SQLException, InstantiationException, ParseException {
        try {
            String date = ContextUtil.getRequestParameter("leavedate1");
            if (!date.equals("")) {
                setDV047(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV047(null);
            }

            date = ContextUtil.getRequestParameter("leavedate2");
            if (!date.equals("")) {
                setDV048(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV048(null);
            }
            date = ContextUtil.getRequestParameter("leavedate3");
            if (!date.equals("")) {
                setDV047T(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV047T(null);
            }

            date = ContextUtil.getRequestParameter("leavedate4");
            if (!date.equals("")) {
                setDV048T(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setDV048T(null);
            }
            System.out.println("--update --v030---------------------------" + FV050 + pn100 + vn033 + vv031);


            V030Store store = new V030Store();
            int count = 0;
            Object listforTour = SessionProvider.getSessionMapValue("listSelected");
            if (listforTour != null) {
                list4Tour = (List<N100>) listforTour;
            }
            System.out.println("--update --v030-----------AAAAAAAAAAAAAAAA----------------" + list4Tour.size());
            if (list4Tour.size() > 0) {
                for (int i = 0; i < list4Tour.size(); i++) {
                    // N100 cus = listKH.get(i);
                    count = store.updateV030(FV050, list4Tour.get(i).getPn100(), vv031, null, this.getVn033(), VV038, VV039, VV040, VV041, VV042, VV043, VV044, VV045, VV046, Util.toSQLDate(DV047), Util.toSQLDate(DV048),
                            VV038T, VV039T, VV040T, VV041T, VV042T, VV043T, VV044T, VV045T, VV046T, Util.toSQLDate(DV047T), Util.toSQLDate(DV048T), null, 0, getLogin().getUserName());
                    System.out.println("---------- CHUYEN nay xay ra bao nhiue alnf----" + VV041);

                }
            }

            if (count != 0) {
                setTip(count);
                listSelected.clear();
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + FV050);

                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
            System.out.println("--update ---------------------------" + count + tip);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(V030controller.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

//    public void saveSelected() {
//        System.out.println("---select+++++++++++++");
//        V030Store store = new V030Store();
//        for (int i = 0; i < listsearch.size(); i++) {
//            System.out.println("---select+++++++++++++" + listsearch.get(i).isSelected() + listsearch.get(i).getHoten());
//
//            try {
//                if (listsearch.get(i).isSelected()) {
//                    System.out.println("---insert v030---" + FV050 + "," + listsearch.get(i).getPn100() + "," + null + "," + null + "," + this.getVn033() + "," + getLogin().getUserName());
//                    store.updateV030(FV050, listsearch.get(i).getPn100(), null, null, this.getVn033(), getLogin().getUserName());
//                    setCheck((Boolean) true);
//                }
//            } catch (Exception ex) {
//                System.out.println("D:-- error from saveSelected customer for tour: "+ex.getMessage());
//                setCheck((Boolean) false);
//            }
//
//        }
//    }
    public void saveSelected(int pn100) {
        V030Store store = new V030Store();
        CustomerStore store1 = new CustomerStore();
        try {
            if (pn100 != 0 && getFV050() != 0) {
                int coutn = 0;
                if (SessionProvider.getSessionMapValue("codetourselectID") != null) {
                    tipTour = Util.parseInt(SessionProvider.getSessionMapValue("codetourselectID"));

                    //  System.out.println("---i-------" + tipTour);
                }
                if (tipTour != 0) {
                    System.out.println("---insert v030 ---" + tipTour + "," + pn100 + "," + null + "," + null + "," + this.getVn033() + "," + getLogin().getUserName());
                    coutn = store.updateV030(tipTour, pn100, vv031, null, this.getVn033(), VV038, VV039, VV040, VV041, VV042, VV043, VV044, VV045, VV046, Util.toSQLDate(DV047), Util.toSQLDate(DV048),
                            VV038T, VV039T, VV040T, VV041T, VV042T, VV043T, VV044T, VV045T, VV046T, Util.toSQLDate(DV047T), Util.toSQLDate(DV048T), VV061, VN062, getLogin().getUserName());
                    //  System.out.println("Change TOUR---" + coutn);
                    setCheck((Boolean) true);
                } else {
                    System.out.println("-" + getFV050() + "," + pn100 + "," + null + "," + null + "," + this.getVn033() + "," + getLogin().getUserName());
                    coutn = store.stdv_tools_inserttabv030new(getFV050(), pn100, vv031, null, this.getVn033(), getLogin().getUserName());
                    int count11 = store1.update2ColumnTAB(null, "V030", "VV042", String.valueOf(""), "FV050", FV050, "FN100", pn100, getLogin().getUserName());
                    // System.out.println("--Not change---" + coutn);
                    setCheck((Boolean) true);
                }

            } else {
                System.out.println("=== If  Eror return---");
            }
        } catch (Exception ex) {
            System.out.println("D:-- error from saveSelected customer for tour: " + ex.getMessage());
            setCheck((Boolean) false);
        }

    }

    public void deleteSelected() {
        //  System.out.println("---select+++++++++++++");
        K400Store store = new K400Store();

        for (int i = 0; i < listremove.size(); i++) {
            //     System.out.println("---select+++++++++++++" + listremove.get(i).isSelected());
            try {
                if (listremove.get(i).isSelected()) {
                    // store.deleteK450(getSessionPK400(),listremove.get(i).getPn100() , "N100", getLogin().getUserName());
                }
            } catch (Exception ex) {
            }

        }
    }

    /**
     * @return the list
     */
    public List<N100> getListIDSearch() {

        V030Store store = new V030Store();
        try {
            // System.out.println("---tttttttttttttttttttttttttttt+++++++++++++" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + FV050 + "," + 0 + "," + getLogin().getUserName());
            // list.add();
        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
        }


        return list;
    }
// List VISA

    public List<N100> getListVisa() {
        V030Store store = new V030Store();
        try {
            if (listVisa == null) {
                listVisa = listVisa();
            }
            System.out.println("TUNG------LIST VÍA------- " + listVisa.size());
            return listVisa;
        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
            return null;
        }


    }

    private List<N100> listVisa() {
        V030Store store = new V030Store();
        try {
            listVisa = store.vcurpks_listoftabv030visa(getLogin().getModule(), getLogin().getCompanyNo(), FN100, FV050, 0, 50, 0, 0, getLogin().getUserName());
            // SessionProvider.setSessionMapValue("listV030", list);
            System.out.println("TUNG------LIST VÍA------- " + listVisa.size());
            return listVisa;
        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
            return null;
        }

    }
// lít nguoi ko thuoc hang khong

    public List<N100> getListV030hk() {
        V030Store store = new V030Store();
        try {
            listV030hk = store.vcurpks_listoftabv030hk(getLogin().getModule(), getLogin().getCompanyNo(), getFV050(), FN100, 0, 50, 0, 0, getLogin().getUserName());
            SessionProvider.setSessionMapValue("listV030", list);
            System.out.println("TUNG------LIST HANG KHONG------- " + listV030hk.size());
            SessionProvider.setSessionMapValue("listV030HK", listV030hk);
            return listV030hk;
        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
            return null;
        }


    }

    public List<N100> getList() {

        V030Store store = new V030Store();
        try {
            // System.out.println("---tttttttttttttttttttttttttttt+++++++++++++" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + FV050 + "," + 0 + "," + getLogin().getUserName());
            if (SessionProvider.getSessionMapValue("IDVISA") != null) {
                idSearch = Util.parseInt(SessionProvider.getSessionMapValue("IDVISA"));
            }
            if (SessionProvider.getSessionMapValue("KEYVISA") != null) {
                keySearch = SessionProvider.getSessionMapValue("KEYVISA").toString();
            }
            if (idSearch == 0) {

                if (SessionProvider.getSessionMapValue("codetourselect") != null) {
                    FV050 = Util.parseInt(SessionProvider.getSessionMapValue("codetourselect"));
                }

                list = store.vcurpks_listoftabv030new(getLogin().getModule(), getLogin().getCompanyNo(), FV050, FN100, 0, 50, 1, 0, getLogin().getUserName());
                if (list != null && list.size() > 0) {
                    CustomerStore customerStore = new CustomerStore();
                    SessionProvider.setSessionMapValue(SessionName.TOUR_NAME, list.get(0).getVv052());
                    SessionProvider.setSessionMapValue(SessionName.TOUR_NAME_UNI, list.get(0).getVv067());
//                    int tem=1;
//                    for (int i = 0; i < list.size(); i++) {
//                        int n100group = 0;
//                        //   SessionProvider.setSessionMapValue("idg", n100group);
//                        System.out.println("--AAAAAAAA--SSSSSSSSSSS------" + n100group);
//                       
//                        if (list.get(i).getPn100cc() == n100group) {
//                            System.out.println("-------------iiiiii----" + i);
//                           
//                            System.out.println("-----bao nhieu row cung id--------iiiiii----" + tem);
//                        } else {
//
//                            if (SessionProvider.getSessionMapValue("idg") != null) {
//                                if (list.get(i).getPn100cc() == Util.parseInt(SessionProvider.getSessionMapValue("idg"))) {
//                                    System.out.println("-A--#0--bao nhieu row cung id--------iiiiii----"+ tem++ );
//                                     int cout6 = customerStore.update2ColumnTAB(null, "V030", "VV041", "DarkGreen", "FV050", FV050, "FN100", list.get(i).getPn100(), getLogin().getUserName());
//                                } else {
//                                    int ddd = list.get(i).getPn100cc();
//                                    SessionProvider.setSessionMapValue("idg", ddd);
//                                    if (list.get(i).getPn100cc() == Util.parseInt(SessionProvider.getSessionMapValue("idg"))) {
//                                        System.out.println("---#0--bao nhieu row cung id--------iiiiii----"+ tem++);
//                                         int cout6 = customerStore.update2ColumnTAB(null, "V030", "VV041", "DarkOrchid", "FV050", FV050, "FN100", list.get(i).getPn100(), getLogin().getUserName());
//                                    }
//                                }
//                            } else {
//                                int ddd = list.get(i).getPn100cc();
//                                SessionProvider.setSessionMapValue("idg", ddd);
//                                if (list.get(i).getPn100cc() == Util.parseInt(SessionProvider.getSessionMapValue("idg"))) {
//                                    System.out.println("---#0--bao nhieu row cung id--------iiiiii----" + tem++);
//                                      int cout6 = customerStore.update2ColumnTAB(null, "V030", "VV041", "DarkGreen", "FV050", FV050, "FN100", list.get(i).getPn100(), getLogin().getUserName());
//                                }
//                            }
//                        }
                    //  }
                }
            } else if (idSearch == 1) {
                list = store.VCURPKS_LISTOFTABV030V(FV050, keySearch, getLogin().getUserName());
            } else if (idSearch == 2) {
                list = store.VCURPKS_LISTOFTABV030V(FV050, keySearch, getLogin().getUserName());
            }



        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
        }
        SessionProvider.setSessionMapValue("listV030", list);
        System.out.println("D:- dang sach khach hang theo tour: " + list.size());
        return list;
    }

    public List<N100> getList1() {

        V030Store store = new V030Store();
        try {
            // System.out.println("---tttttttttttttttttttttttttttt+++++++++++++" + getLogin().getModule() + "," + getLogin().getCompanyNo() + "," + FV050 + "," + 0 + "," + getLogin().getUserName());
            if (SessionProvider.getSessionMapValue("IDVISA") != null) {
                idSearch = Util.parseInt(SessionProvider.getSessionMapValue("IDVISA"));
            }
            if (SessionProvider.getSessionMapValue("KEYVISA") != null) {
                keySearch = SessionProvider.getSessionMapValue("KEYVISA").toString();
            }
            if (idSearch == 0) {
                list = store.listV030(getLogin().getModule(), getLogin().getCompanyNo(), FV050, 0, pnsoft, getLogin().getUserName());
                System.out.println("--------------LIST cua V050 FOR TOUR----" + list.size());
            } else if (idSearch == 1) {
                list = store.VCURPKS_LISTOFTABV030V(FV050, keySearch, getLogin().getUserName());
            } else if (idSearch == 2) {
                list = store.VCURPKS_LISTOFTABV030V(FV050, keySearch, getLogin().getUserName());
            }



        } catch (Exception e) {
            System.out.println("error" + e.getMessage());
        }
        SessionProvider.setSessionMapValue("listV030", list);
        System.out.println("D:- dang sach khach hang theo tour: " + list.size());
        return list;
    }

    // View tai lieu theo khach hang theo tour
    public List<M650> getListdocumentM650() {
        M650Store store = new M650Store();
        try {

            List<M650> listM650 = store.findM650(getLogin().getModule(), getLogin().getCompanyNo(), 0, null, 0, 0, 0, null, "V030", FV050, pn100, null, null, 0, 10000, 0, 0, getLogin().getUserName());
            //  System.out.println("--------------------------" + listM650.size() + FV050 + pn100);
            return listM650;
        } catch (Exception e) {
            return null;
        }
    }

    public List<N100> getListpersonalTour() {
        try {
            EmployeeStore store = new EmployeeStore();
            List<N100> listN10000 = store.comboboxForTour(getLogin().getModule(), getLogin().getCompanyNo(), FV050, getLogin().getUserName());
//           N100 n100 = new N100();
//           listN10000.add(0,n100.getNamecombox());
            //  System.out.println("--------------------------" + listN10000.size() + FV050);
            return listN10000;
        } catch (Exception e) {
            return null;
        }
    }

    public List<M650> getListdocumentM650M() {
        M650Store store = new M650Store();
        try {

            List<M650> listM650 = store.findM650(getLogin().getModule(), getLogin().getCompanyNo(), 0, null, 0, 0, 0, null, "M575", pm575, 0, null, "MAIL", 0, 10000, 0, 0, getLogin().getUserName());

            return listM650;
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * @param list the list to set
     */
    public void setList(List<N100> list) {


        this.list = list;
    }

    /**
     * @return the listremove
     */
    public List<N100> getListremove() {
        CustomerStore store = new CustomerStore();
        if (keysearch.contains("Nhập từ khóa")) {
            keysearch = "";
        }
        //listremove = store.removeListCustomer(getLogin().getModule(), 99, getSessionPK400(), keysearch, getLogin().getUserName());
        System.out.println("list remove***" + "--" + listremove);
        return listremove;
    }

    /**
     * @param listremove the listremove to set
     */
    public void setListremove(List<N100> listremove) {
        this.listremove = listremove;
    }

    /**
     * @return the keysearch
     */
    public String getKeysearch() {
        return keysearch;
    }

    /**
     * @param keysearch the keysearch to set
     */
    public void setKeysearch(String keysearch) {
        this.keysearch = keysearch;
    }

    /**
     * @return the PV030
     */
    public int getPV030() {
        return PV030;
    }

    /**
     * @param PV030 the PV030 to set
     */
    public void setPV030(int PV030) {
        this.PV030 = PV030;
    }

    /**
     * @return the listsearch
     */
    public List<N100> getListsearch() {
        V030Store store = new V030Store();
        try {
            if (keysearch.contains("Nhập từ khóa")) {
                keysearch = "";
            }
            System.out.println("---aaaaaaaaa+++++++++++++" + getFV050());
            listsearch = store.searchListV030(getLogin().getModule(), getLogin().getCompanyNo(), getFV050(), getLogin().getCharacter(), keysearch, getLogin().getUserName());
            System.out.println("aaaaaaaaaz size" + listsearch.size());
        } catch (Exception e) {
        }
        return listsearch;
    }

    /**
     * @param listsearch the listsearch to set
     */
    public void setListsearch(List<N100> listsearch) {
        this.listsearch = listsearch;
    }

    /**
     * @return the combV050
     */
    public List<SelectItem> getCombV050() {
        ComboboxUtil combo = new ComboboxUtil();
        combV050 = combo.getListCombV050SGT();
        return combV050;
    }

    public List<V500> getListitemV050() {
        try {
            V500Store v500Store = new V500Store();
            List<V500> listV500 = v500Store.getListCombV050SGT(getLogin().getModule(), getLogin().getCompanyNo(), null, "T", getLogin().getUserName());
            return listV500;
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * @param combV050 the combV050 to set
     */
    public void setCombV050(List<SelectItem> combV050) {
        this.combV050 = combV050;
    }

    /**
     * @return the FV050
     */
    public int getFV050() {
        if (SessionProvider.getSessionMapValue("codetourselect") != null) {
            FV050 = Integer.parseInt(SessionProvider.getSessionMapValue("codetourselect").toString());
        }
        return FV050;
    }

    /**
     * @param FV050 the FV050 to set
     */
    public void setFV050(int FV050) {
        this.FV050 = FV050;
    }

    /**
     * @return the flag
     */
    public int getFlag() {
        return flag;
    }

    /**
     * @param flag the flag to set
     */
    public void setFlag(int flag) {
        this.flag = flag;
    }

    /**
     * @return the vn033
     */
    public double getVn033() {
        return vn033;
    }

    /**
     * @param vn033 the vn033 to set
     */
    public void setVn033(double vn033) {
        this.vn033 = vn033;
    }

    /**
     * @return the pn100
     */
    public int getPn100() {
        return pn100;
    }

    /**
     * @param pn100 the pn100 to set
     */
    public void setPn100(int pn100) {
        this.pn100 = pn100;
    }

    /**
     * @return the beginContructor
     */
    public int getBeginContructor() {
        return beginContructor;
    }

    /**
     * @param beginContructor the beginContructor to set
     */
    public void setBeginContructor(int beginContructor) {
        this.beginContructor = beginContructor;
    }

    /**
     * @return the vv031
     */
    public String getVv031() {
        return vv031;
    }

    /**
     * @param vv031 the vv031 to set
     */
    public void setVv031(String vv031) {
        this.vv031 = vv031;
    }

    /**
     * @return the vn034
     */
    public int getVn034() {
        return vn034;
    }

    /**
     * @param vn034 the vn034 to set
     */
    public void setVn034(int vn034) {
        this.vn034 = vn034;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        Object objstt = SessionProvider.getSessionMapValue("status");
        if (objstt != null) {
            status = objstt.toString().trim();
        }
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the check
     */
    public Boolean getCheck() {
        return check;
    }

    /**
     * @param check the check to set
     */
    public void setCheck(Boolean check) {
        this.check = check;
    }

    /**
     * @return the vn035
     */
    public int getVn035() {
        return vn035;
    }

    /**
     * @param vn035 the vn035 to set
     */
    public void setVn035(int vn035) {
        this.vn035 = vn035;
    }

    /**
     * @return the tip
     */
    public int getTip() {
        return tip;
    }

    /**
     * @param tip the tip to set
     */
    public void setTip(int tip) {
        this.tip = tip;
    }

    /**
     * @return the empString
     */
    public String getEmpString() {
        return empString;
    }

    /**
     * @param empString the empString to set
     */
    public void setEmpString(String empString) {
        this.empString = empString;
    }

    /**
     * @return the pm575
     */
    public int getPm575() {
        return pm575;
    }

    /**
     * @param pm575 the pm575 to set
     */
    public void setPm575(int pm575) {
        this.pm575 = pm575;
    }

    /**
     * @return the tipTour
     */
    public int getTipTour() {
        if (SessionProvider.getSessionMapValue("codetourselectID") != null) {
            tipTour = Util.parseInt(SessionProvider.getSessionMapValue("codetourselectID"));

            System.out.println("---i-------" + tipTour);
        }
        return tipTour;
    }

    /**
     * @param tipTour the tipTour to set
     */
    public void setTipTour(int tipTour) {
        this.tipTour = tipTour;
    }
    //xuat excel

    public void exportExcel() {
        //String path = "E:\\qapi\\build\\web\\resources\\excel" + "\\report.xls";
        String s = getRequest().getRequestURL().toString();
        String[] arr = new String[20];
        arr = s.split("/");
        String url = "";
        if (arr.length > 3) {
            url = arr[0] + "/" + arr[1] + "/" + arr[2] + "/";
        }
        try {


            HSSFCellStyle styleTitle = (HSSFCellStyle) wb.createCellStyle();
            styleTitle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            styleTitle.setAlignment(CellStyle.ALIGN_CENTER);
            styleTitle.setWrapText(true);
            HSSFFont font = (HSSFFont) wb.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            font.setFontHeightInPoints((short) 12);
            font.setFontName("Arial");

            styleTitle.setFont(font);

            HSSFCellStyle styleHeader = (HSSFCellStyle) wb.createCellStyle();
            styleHeader.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            styleHeader.setAlignment(CellStyle.ALIGN_CENTER);
            styleHeader.setWrapText(true);
            styleHeader.setFillForegroundColor(HSSFColor.ROYAL_BLUE.index);
            styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
            styleHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleHeader.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleHeader.setBorderTop(HSSFCellStyle.BORDER_THIN);

            HSSFFont font2 = (HSSFFont) wb.createFont();
            font2.setFontName("Arial");
            font2.setFontHeightInPoints((short) 10);
            font2.setFontHeightInPoints((short) 10);
            styleHeader.setFont(font2);


            HSSFCellStyle styleLeft = (HSSFCellStyle) wb.createCellStyle();
            styleLeft.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            styleLeft.setAlignment(CellStyle.ALIGN_LEFT);
            styleLeft.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleLeft.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleLeft.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleLeft.setWrapText(true);

            HSSFCellStyle styleCenter = (HSSFCellStyle) wb.createCellStyle();
            styleCenter.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            styleCenter.setAlignment(CellStyle.ALIGN_CENTER);
            styleCenter.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleCenter.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleCenter.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleCenter.setWrapText(true);

            HSSFCellStyle styleRight = (HSSFCellStyle) wb.createCellStyle();
            styleRight.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
            styleRight.setAlignment(CellStyle.ALIGN_RIGHT);
            styleRight.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleRight.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleRight.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleRight.setWrapText(true);
//            HSSFFont font3 = (HSSFFont) wb.createFont();
//            font3.setFontName("Arial");
//            font3.setFontHeightInPoints((short) 10);
//
//            styleHeader.setFont(font3);


            Sheet sheet = wb.createSheet("KH theo tour");
            Row rowTitle = sheet.createRow(currentRow);
            sheet.addMergedRegion(new CellRangeAddress(currentRow, currentRow, 0, 5));
            Cell cellTitle = rowTitle.createCell(0, 4);
            cellTitle.setCellValue("Danh sách khách hàng theo tour");
            cellTitle.setCellStyle(styleTitle);

            currentRow = currentRow + 2;
            sheet = createHeader(sheet, currentRow, styleHeader);
            currentRow++;
            sheet = createContent(sheet, currentRow, styleLeft, styleCenter, styleRight);
            String tempStr = ResourcesProvider.getReportExcel();
            if (!(new File(tempStr)).exists()) {
                (new File(tempStr)).mkdirs();
            }
            //setup print
            PrintSetup ps = sheet.getPrintSetup();
            sheet.setAutobreaks(true);
            sheet.setMargin(Sheet.LeftMargin, 0.5);
            sheet.setMargin(Sheet.RightMargin, 0.5);

            ps.setLandscape(true);
            ps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);
            ps.setFitWidth((short) 0);
            ps.setFitHeight((short) 0);
            //end setup print

            File fileout = new File(ResourcesProvider.getReportExcel() + "report.xls");
            FileOutputStream fileOut = new FileOutputStream(fileout);
            wb.write(fileOut);
            fileOut.close();

            sendRedirect(url + "resources/excel/report.xls");

            System.out.println("sendRedirect----:" + ResourcesProvider.getReportExcel() + "report.xls");
//            sendRedirect("E://Q_//kapi//build//web//resources//excel//" + "report.xls");

        } catch (Exception e) {
        }




    }

    private Sheet createHeader(Sheet sheet, int row, HSSFCellStyle style) {
        List<SelectItem> header = new ArrayList<SelectItem>();
//        header.add(new SelectItem(2000, "Phòng"));
//        header.add(new SelectItem(7000, "Họ tên"));
//        header.add(new SelectItem(3000, "CMND"));
//        header.add(new SelectItem(12000, "Email"));
//        header.add(new SelectItem(3000, "Điện thoại"));
//        header.add(new SelectItem(12000, "Địa chỉ"));
//        header.add(new SelectItem(3000, "Giá bán"));
        header.add(new SelectItem(7000, "HỌ TÊN"));
        header.add(new SelectItem(3000, "NGÀY SINH"));
        header.add(new SelectItem(6000, "CMND / PASSPORT"));
        header.add(new SelectItem(3000, "NGÀY HẾT HẠN"));
        header.add(new SelectItem(3000, "PHÒNG"));
        header.add(new SelectItem(8000, "GHI CHÚ"));
        Row row_header = sheet.createRow(row);
        for (int i = 0; i < header.size(); i++) {
            Cell c = row_header.createCell(i);
            c.setCellValue(header.get(i).getLabel());
            c.setCellStyle(style);
            sheet.setColumnWidth(i, Integer.parseInt(header.get(i).getValue().toString()));
        }
        return sheet;
    }

    private Sheet createContent(Sheet sheet, int row, HSSFCellStyle left, HSSFCellStyle center, HSSFCellStyle right) {
        try {
            V030Store store = new V030Store();
            if (SessionProvider.getSessionMapValue("codetourselect") != null) {
                FV050 = Integer.parseInt(SessionProvider.getSessionMapValue("codetourselect").toString());
            }

            System.out.println("createContent--" + FV050);
            lstExportExcel = list = store.listV030(getLogin().getModule(), getLogin().getCompanyNo(), FV050, 0, pnsoft, getLogin().getUserName());
            System.out.println("D:- Danh sach khach hang xuat Excel: " + lstExportExcel.size());
            for (int i = 0; i < lstExportExcel.size(); i++) {
                try {
                    N100 n100 = lstExportExcel.get(i);
                    Row r = sheet.createRow(row);
//                    Cell c0 = r.createCell(0);
//                    if (n100.getVv037() != null) {
//                        c0.setCellValue(n100.getVv037());
//                    }
//                    c0.setCellStyle(left);

                    //ho ten
                    Cell c = r.createCell(0);
                    if (n100.getHoten() != null) {
                        c.setCellValue(n100.getHoten());
                    }
                    c.setCellStyle(left);

                    //ngay sinh
                    Cell c1 = r.createCell(1);
                    if (n100.getNd118() != null) {

                        c1.setCellValue(sdf.format(Util.toSQLDate(n100.getNd118())));
                    }

                    c1.setCellStyle(center);

                    //passport
                    Cell c2 = r.createCell(2);
                    if (n100.getNv110() != null) {
                        c2.setCellValue(n100.getNv110());
                    }

                    c2.setCellStyle(center);

                    //ngay het han
                    Cell c3 = r.createCell(3);
                    if (n100.getNd352() != null) {
                        c3.setCellValue(sdf.format(Util.toSQLDate(n100.getNd352())));
                    }
                    c3.setCellStyle(center);

                    //phong
                    Cell c4 = r.createCell(4);
                    if (n100.getVv037() != null) {
                        c4.setCellValue(n100.getVv037());
                    }
                    c4.setCellStyle(center);

                    //ghi chu
                    Cell c5 = r.createCell(5);

                    c5.setCellStyle(left);
                    row++;
                } catch (Exception e) {
                    System.out.println("D:- Error from row: " + i + " -- " + e.getMessage());
                    continue;
                }

            }
        } catch (Exception e) {
            System.out.println("D:- error from export excel: " + e.getMessage());
        }
        return sheet;
    }
    //end excel

    /**
     * @return the combV050ForTour
     */
    public List<SelectItem> getCombV050ForTour() {

        ComboboxUtil cbb = new ComboboxUtil();
        combV050ForTour = cbb.getlistCombForTour(FV050);


        return combV050ForTour;
    }

    /**
     * @param combV050ForTour the combV050ForTour to set
     */
    public void setCombV050ForTour(List<SelectItem> combV050ForTour) {
        this.combV050ForTour = combV050ForTour;
    }

    /**
     * @return the vv036
     */
    public String getVv036() {
        return vv036;
    }

    /**
     * @param vv036 the vv036 to set
     */
    public void setVv036(String vv036) {
        this.vv036 = vv036;
    }

    /**
     * @return the listsearchDD
     */
    public List<N100> getListsearchDD() {
        V030Store store = new V030Store();
        try {
            if (keysearch.contains("Nhập từ khóa")) {
                keysearch = "";
            }
            listsearchDD = store.getListpersonalDD(getLogin().getModule(), getLogin().getCompanyNo(), keysearch, getLogin().getUserName());
            System.out.println("aaaaaaaaaz size" + listsearchDD.size());
        } catch (Exception e) {
        }

        return listsearchDD;
    }

    /**
     * @param listsearchDD the listsearchDD to set
     */
    public void setListsearchDD(List<N100> listsearchDD) {
        this.listsearchDD = listsearchDD;
    }

    /**
     * @return the pnsoft
     */
    public int getPnsoft() {
        return pnsoft;
    }

    /**
     * @param pnsoft the pnsoft to set
     */
    public void setPnsoft(int pnsoft) {
        this.pnsoft = pnsoft;
    }

    /**
     * @return the VV038
     */
    public String getVV038() {
        return VV038;
    }

    /**
     * @param VV038 the VV038 to set
     */
    public void setVV038(String VV038) {
        this.VV038 = VV038;
    }

    /**
     * @return the VV039
     */
    public String getVV039() {
        return VV039;
    }

    /**
     * @param VV039 the VV039 to set
     */
    public void setVV039(String VV039) {
        this.VV039 = VV039;
    }

    /**
     * @return the VV040
     */
    public String getVV040() {
        return VV040;
    }

    /**
     * @param VV040 the VV040 to set
     */
    public void setVV040(String VV040) {
        this.VV040 = VV040;
    }

    /**
     * @return the VV041
     */
    public String getVV041() {
        return VV041;
    }

    /**
     * @param VV041 the VV041 to set
     */
    public void setVV041(String VV041) {
        this.VV041 = VV041;
    }

    /**
     * @return the VV042
     */
    public String getVV042() {
        return VV042;
    }

    /**
     * @param VV042 the VV042 to set
     */
    public void setVV042(String VV042) {
        this.VV042 = VV042;
    }

    /**
     * @return the VV043
     */
    public String getVV043() {
        return VV043;
    }

    /**
     * @param VV043 the VV043 to set
     */
    public void setVV043(String VV043) {
        this.VV043 = VV043;
    }

    /**
     * @return the VV044
     */
    public String getVV044() {
        return VV044;
    }

    /**
     * @param VV044 the VV044 to set
     */
    public void setVV044(String VV044) {
        this.VV044 = VV044;
    }

    /**
     * @return the VV045
     */
    public String getVV045() {
        return VV045;
    }

    /**
     * @param VV045 the VV045 to set
     */
    public void setVV045(String VV045) {
        this.VV045 = VV045;
    }

    /**
     * @return the idSearch
     */
    public int getIdSearch() {
        return idSearch;
    }

    /**
     * @param idSearch the idSearch to set
     */
    public void setIdSearch(int idSearch) {
        this.idSearch = idSearch;
    }

    /**
     * @return the keySearch
     */
    public String getKeySearch() {
        return keySearch;
    }

    /**
     * @param keySearch the keySearch to set
     */
    public void setKeySearch(String keySearch) {
        this.keySearch = keySearch;
    }

    /**
     * @return the listpersonalforTour
     */
    public String getListpersonalforTour() {
        return listpersonalforTour;
    }

    /**
     * @param listpersonalforTour the listpersonalforTour to set
     */
    public void setListpersonalforTour(String listpersonalforTour) {
        this.listpersonalforTour = listpersonalforTour;
    }

    /**
     * @return the list4Tour
     */
    public List<N100> getList4Tour() {
        return list4Tour;
    }

    /**
     * @param list4Tour the list4Tour to set
     */
    public void setList4Tour(List<N100> list4Tour) {
        this.list4Tour = list4Tour;
    }

    /**
     * @return the VV046
     */
    public String getVV046() {
        return VV046;
    }

    /**
     * @param VV046 the VV046 to set
     */
    public void setVV046(String VV046) {
        this.VV046 = VV046;
    }

    /**
     * @return the DV047
     */
    public Date getDV047() {
        return DV047;
    }

    /**
     * @param DV047 the DV047 to set
     */
    public void setDV047(Date DV047) {
        this.DV047 = DV047;
    }

    /**
     * @return the DV048
     */
    public Date getDV048() {
        return DV048;
    }

    /**
     * @param DV048 the DV048 to set
     */
    public void setDV048(Date DV048) {
        this.DV048 = DV048;
    }

    /**
     * @return the VV038T
     */
    public String getVV038T() {
        return VV038T;
    }

    /**
     * @param VV038T the VV038T to set
     */
    public void setVV038T(String VV038T) {
        this.VV038T = VV038T;
    }

    /**
     * @return the VV039T
     */
    public String getVV039T() {
        return VV039T;
    }

    /**
     * @param VV039T the VV039T to set
     */
    public void setVV039T(String VV039T) {
        this.VV039T = VV039T;
    }

    /**
     * @return the VV040T
     */
    public String getVV040T() {
        return VV040T;
    }

    /**
     * @param VV040T the VV040T to set
     */
    public void setVV040T(String VV040T) {
        this.VV040T = VV040T;
    }

    /**
     * @return the VV041T
     */
    public String getVV041T() {
        return VV041T;
    }

    /**
     * @param VV041T the VV041T to set
     */
    public void setVV041T(String VV041T) {
        this.VV041T = VV041T;
    }

    /**
     * @return the VV042T
     */
    public String getVV042T() {
        return VV042T;
    }

    /**
     * @param VV042T the VV042T to set
     */
    public void setVV042T(String VV042T) {
        this.VV042T = VV042T;
    }

    /**
     * @return the VV043T
     */
    public String getVV043T() {
        return VV043T;
    }

    /**
     * @param VV043T the VV043T to set
     */
    public void setVV043T(String VV043T) {
        this.VV043T = VV043T;
    }

    /**
     * @return the VV044T
     */
    public String getVV044T() {
        return VV044T;
    }

    /**
     * @param VV044T the VV044T to set
     */
    public void setVV044T(String VV044T) {
        this.VV044T = VV044T;
    }

    /**
     * @return the VV045T
     */
    public String getVV045T() {
        return VV045T;
    }

    /**
     * @param VV045T the VV045T to set
     */
    public void setVV045T(String VV045T) {
        this.VV045T = VV045T;
    }

    /**
     * @return the VV046T
     */
    public String getVV046T() {
        return VV046T;
    }

    /**
     * @param VV046T the VV046T to set
     */
    public void setVV046T(String VV046T) {
        this.VV046T = VV046T;
    }

    /**
     * @return the DV047T
     */
    public Date getDV047T() {
        return DV047T;
    }

    /**
     * @param DV047T the DV047T to set
     */
    public void setDV047T(Date DV047T) {
        this.DV047T = DV047T;
    }

    /**
     * @return the DV048T
     */
    public Date getDV048T() {
        return DV048T;
    }

    /**
     * @param DV048T the DV048T to set
     */
    public void setDV048T(Date DV048T) {
        this.DV048T = DV048T;
    }

    /**
     * @return the VN062
     */
    public int getVN062() {
        return VN062;
    }

    /**
     * @param VN062 the VN062 to set
     */
    public void setVN062(int VN062) {
        this.VN062 = VN062;
    }

    /**
     * @return the VV061
     */
    public String getVV061() {
        return VV061;
    }

    /**
     * @param VV061 the VV061 to set
     */
    public void setVV061(String VV061) {
        this.VV061 = VV061;
    }

    /**
     * @return the tabString
     */
    public String getTabString() {
        if (SessionProvider.getSessionMapValue("TABNTG") != null) {
            tabString = SessionProvider.getSessionMapValue("TABNTG").toString();
        } else {
        }
        return tabString;
    }

    /**
     * @param tabString the tabString to set
     */
    public void setTabString(String tabString) {
        this.tabString = tabString;
    }

    public void chooseTabntg() {
        try {
            if (SessionProvider.getSessionMapValue("listSelected") != null) {
                SessionProvider.setSessionMapValue("listSelected", null);
                listSelected = (List<N100>) SessionProvider.getSessionMapValue("listSelected");
            }
            if (SessionProvider.getSessionMapValue("listSelectedHK") != null) {
                SessionProvider.setSessionMapValue("listSelectedHK", null);
                listSelected = (List<N100>) SessionProvider.getSessionMapValue("listSelectedHK");
            }
            if (SessionProvider.getSessionMapValue("selected") != null) {
                SessionProvider.setSessionMapValue("selected", null);
                listSelected = (List<N100>) SessionProvider.getSessionMapValue("selected");
            }
            setTabString("TABNTG");
            System.out.println("-----------------------TABSTRING---------------" + tabString);
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabvisa() {
        try {
            setTabString("TABVISA");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }
    
    public void chooseTabndd() {
        try {
            setTabString("TABNDD");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabpc() {
        try {
            setTabString("TABPC");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
            if (SessionProvider.getSessionMapValue("selected") != null) {
                SessionProvider.setSessionMapValue("selected", null);
                listSelected = (List<N100>) SessionProvider.getSessionMapValue("selected");
            }
        } catch (Exception e) {
        }
    }

    public void chooseTabbus() {
        try {
            setTabString("TABBUS");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabcn() {
        try {
            setTabString("TABCN");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabkh() {
        try {
            setTabString("TABHK");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
            if (SessionProvider.getSessionMapValue("selected") != null) {
                SessionProvider.setSessionMapValue("selected", null);
                listSelected = (List<N100>) SessionProvider.getSessionMapValue("selected");
            }
        } catch (Exception e) {
        }
    }

    public void chooseTabdoc() {
        try {
            setTabString("TABDOC");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabsms() {
        try {
            setTabString("TABSMS");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void chooseTabchiti() {
        try {
            setTabString("TABCHITI");
            SessionProvider.setSessionMapValue("TABNTG", tabString);
        } catch (Exception e) {
        }
    }

    public void deleteV0301() {

        try {
            getList();
        } catch (Exception e) {
        }
    }

    /**
     * @return the FN100
     */
    public int getFN100() {
        return FN100;
    }

    /**
     * @param FN100 the FN100 to set
     */
    public void setFN100(int FN100) {
        this.FN100 = FN100;
    }

    public void stdv_tools_updatetabv030roo() {
        try {
            V030Store v030Store = new V030Store();

            List<N100> listHK = new ArrayList<N100>();
            if (SessionProvider.getSessionMapValue("listSelectedHK") != null) {
                listHK = (List<N100>) SessionProvider.getSessionMapValue("listSelectedHK");
            }
            int count = 0;
            if (listHK != null) {
                for (int i = 0; i < listHK.size(); i++) {
                    System.out.println("-----THAM SO PHOIC OC=----" + getFV050() + "," + listHK.get(i).getPn100() + "," + vnn035 + "," + vv036 + "," + VV038 + "," + getLogin().getUserName());
                    count = v030Store.stdv_tools_updatetabv030roo(getFV050(), listHK.get(i).getPn100(), vnn035, vv036, VV038, getLogin().getUserName());
                }
            }

            System.out.println("-------------COUNT PHONG OC--------" + count);
            if (count > 0) {
                showGlobalReport(true, getResourceString("success"));
            } else {
                showGlobalReport(true, getResourceString("error"));
            }
            sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + getFV050() + "&action=delSS");
        } catch (Exception e) {
        }
    }

    /**
     * @return the vnn035
     */
    public int getVnn035() {
        return vnn035;
    }

    /**
     * @param vnn035 the vnn035 to set
     */
    public void setVnn035(int vnn035) {
        this.vnn035 = vnn035;
    }

    /**
     * @return the vnn036
     */
    public int getVnn036() {
        return vnn036;
    }

    /**
     * @param vnn036 the vnn036 to set
     */
    public void setVnn036(int vnn036) {
        this.vnn036 = vnn036;
    }

    /**
     * @return the vnn037
     */
    public int getVnn037() {
        return vnn037;
    }

    /**
     * @param vnn037 the vnn037 to set
     */
    public void setVnn037(int vnn037) {
        this.vnn037 = vnn037;
    }

    /**
     * @return the listV030Room
     */
    public List<N100> getListV030Room() {
        try {
            V030Store v030 = new V030Store();
            System.out.println("tong so nguoi trong tuor : =" + getLogin().getModule()+","
                    +getLogin().getCompanyNo()+","
                    +getFV050()+","
                    +pn100+","
                    +0+","
                    +200+","
                    +0+","
                    +0+","
                    +getLogin().getUserName());
            listV030Room = v030.vcurpks_listoftabv030roo(getLogin().getModule(), getLogin().getCompanyNo(), getFV050(), pn100, 0, 200, 0, 0, getLogin().getUserName());
            if(listV030Room.size() >0){
                tongsonguoi = listV030Room.size();
                int songuoithieu=0;
                String songuoitrung = "";
                String songuoitrung1 ="";
                for(int j = 0 ; j < listV030Room.size(); j++){
                    songuoitrung1 =listV030Room.get(j).getVv037();
 
                    if(listV030Room.get(j).getVv037() !=null && listV030Room.get(j).getVv037()!=""){
                            if(songuoitrung1.equals(songuoitrung)){
                                System.out.println("-----------AAAAAAAA----------------");
                            }else{
                                tongsophongDK +=1; 
                            }

                    }else{
                        tongsonguoiKP +=1;
                        tongsonguoiCP = (tongsonguoi- tongsonguoiKP);
                    }
                    songuoitrung = listV030Room.get(j).getVv037();
                    
                }
                SessionProvider.setSessionMapValue("LISTV030ROOM", listV030Room);
            }
            listngayTour = (List<V050>) SessionProvider.getSessionMapValue("LISTV050ROOM");
            if(listngayTour.size() >0 && listngayTour !=null){
               for(int i = 0 ; i < listngayTour.size() ; i++){
                    ngaybatdau = listngayTour.get(i).getVd073();
                    ngayketthuc = listngayTour.get(i).getVd074();
               }
               if(ngaybatdau !=null && ngayketthuc != null){
                    System.out.println("-----------Calendar----------"+ ngaybatdau +"----"+ngayketthuc);
                    longdate = (ngayketthuc.getTime() - ngaybatdau.getTime()) / (24 * 60 * 60 * 1000);
                    int a = (int) longdate;
                    listngay.add(a);
                    System.out.println("-----------Calendar1----------" + a);

                }
            }
            System.out.println("------LIST IN ROMOM------" + listV030Room.size());
        } catch (Exception e) {
        }
        return listV030Room;
    }

    /**
     * @param listV030Room the listV030Room to set
     */
    public void setListV030Room(List<N100> listV030Room) {
        this.listV030Room = listV030Room;
    }

    /**
     * @param listV030hk the listV030hk to set
     */
    public void setListV030hk(List<N100> listV030hk) {
        this.setListV030hk(listV030hk);
    }

    /**
     * @return the tourname
     */
    public String getTourname() {
        if (SessionProvider.getSessionMapValue(SessionName.TOUR_NAME) != null) {
            tourname = SessionProvider.getSessionMapValue(SessionName.TOUR_NAME).toString();
            System.out.println("SessionProvider.getSessionMapValue(SessionName.TOUR_NAME)-----" + tourname + "---" + SessionProvider.getSessionMapValue(SessionName.TOUR_NAME));
        }
        return tourname;
    }

    /**
     * @param tourname the tourname to set
     */
    public void setTourname(String tourname) {
        this.tourname = tourname;
    }

    /**
     * @return the flagAcviteVisa
     */
    public int getFlagAcviteVisa() {

        if (SessionProvider.getSessionMapValue("listSelected") != null) {
            flagAcviteVisa = 1;
        } else {
            flagAcviteVisa = 0;
        }

        return flagAcviteVisa;
    }

    /**
     * @param flagAcviteVisa the flagAcviteVisa to set
     */
    public void setFlagAcviteVisa(int flagAcviteVisa) {
        this.flagAcviteVisa = flagAcviteVisa;
    }

    /**
     * @return the active
     */
    public String getActive() {
        if (listVisa == null) {
            listVisa = listVisa();
        }
        if (listVisa != null && listVisa.size() > 0) {
            active = listVisa.get(0).getVv045();
        }
        return active;
    }

    /**
     * @param active the active to set
     */
    public void setActive(String active) {
        this.active = active;
    }

//    /**
//     * @return the listoftabM020
//     */
//    public List<M020> getListoftabM020() {
//        try {
//            System.out.println("-------LIST SMS--------"+ getLogin().getModule()+","+ getLogin().getCompanyNo()+","+ fv050+","+ fn100+","+ md023+","+ md024+","+mn026+","+ getLogin().getUserName());
//            listoftabM020 = m020Store.mcurpks_listoftabm020(getLogin().getModule(), getLogin().getCompanyNo(), fv050, fn100, md023, md024,mn026, getLogin().getUserName());
//            return listoftabM020;
//        } catch (Exception e) {
//            return null;
//        }
//
//    }
//    }
//
//    /**
//     * @param listoftabM020 the listoftabM020 to set
//     */
//    public void setListoftabM020(List<M020> listoftabM020) {
//        this.listoftabM020 = listoftabM020;
//    }
    /**
     * @return the tourcode
     */
    public String getTourcode() {
        if (SessionProvider.getSessionMapValue(SessionName.TOUR_CODE) != null) {
            tourcode = SessionProvider.getSessionMapValue(SessionName.TOUR_CODE).toString();

        }
        return tourcode;
    }

    /**
     * @param tourcode the tourcode to set
     */
    public void setTourcode(String tourcode) {
        this.tourcode = tourcode;
    }


    // đoi mau cho nguoiu gioit hieu
    public void updatepersonaldd(int pn100, int FV050, int vn062,String vv061) {
        try {
           
            CustomerStore customer = new CustomerStore();
            int count = customer.update2ColumnTAB(null, "V030", "VN062", String.valueOf(vn062), "FV050", FV050, "FN100", pn100, getLogin().getUserName());
            int count2 = customer.update2ColumnTAB(null, "V030", "VV061", vv061, "FV050", FV050, "FN100", pn100, getLogin().getUserName());
             int coun1 = customer.update2ColumnTAB(null, "V030", "FN100C", String.valueOf(pn100), "FV050", FV050, "FN100", pn100, getLogin().getUserName());
             System.out.println("------------NGUOI DAI DIEN UPDATE--------" + count);

        } catch (Exception e) {
        }
    }

    /**
     * @return the checkndd
     */
    public boolean isCheckndd() {
        if (SessionProvider.getSessionMapValue("checkndd4tour") != null) {
            checkndd = Boolean.valueOf(SessionProvider.getSessionMapValue("checkndd4tour").toString());
        }
        return checkndd;
    }

    /**
     * @param checkndd the checkndd to set
     */
    public void setCheckndd(boolean checkndd) {
        this.checkndd = checkndd;
    }

    /**
     * @return the checkngt
     */
    public boolean isCheckngt() {
        if (SessionProvider.getSessionMapValue("checkngt4tour") != null) {
            checkngt = Boolean.valueOf(SessionProvider.getSessionMapValue("checkngt4tour").toString());
        }
        return checkngt;
    }

    /**
     * @param checkngt the checkngt to set
     */
    public void setCheckngt(boolean checkngt) {
        this.checkngt = checkngt;
    }


    /**
     * @return the combV030New
     */
    public List<SelectItem> getCombV030New() {
        ComboboxUtil cb = new ComboboxUtil();
        try {
            combV030New = cb.getSelectedV030forTourNewDD(getFV050());
        } catch (Exception e) {
        }
        return combV030New;
    }

    /**
     * @param combV030New the combV030New to set
     */
    public void setCombV030New(List<SelectItem> combV030New) {
        this.combV030New = combV030New;
    }

    /**
     * @return the listpersonalDD
     */
    public List<N100> getListpersonalDD() {
        try {
            V030Store v030Store = new V030Store();
             listpersonalDD = v030Store.vcurpks_listoftabv030dd(FV050, 0,0,getLogin().getUserName());
        } catch (Exception e) {
        }
        return listpersonalDD;
    }

    /**
     * @param listpersonalDD the listpersonalDD to set
     */
    public void setListpersonalDD(List<N100> listpersonalDD) {
        this.listpersonalDD = listpersonalDD;
    }
    
    public void onchangecolor1(){
        try {
            CustomerStore store = new  CustomerStore();
            if(listSelected!=null){
                for(int i=0;i<listSelected.size();i++){
                    int count = store.update2ColumnTAB(null, "V030","FN100C",String.valueOf(pn100), "FV050", FV050, "FN100",listSelected.get(i).getPn100(), getLogin().getUserName());
                    if(pn100!=0){
                          V030Store v030Store = new V030Store();
                        List<N100> newlist= v030Store.vcurpks_listoftabv030dd(FV050, 0, pn100, getLogin().getUserName());
                        System.out.println("----------------LIST------TOUR     NDD------"+newlist.size());
                        if(newlist!=null){
                              System.out.println("----------------LIST-------------------AAAAAAAAAAAAAAAAA-----"+newlist.get(0).getVv061());
                               int count1 = store.update2ColumnTAB(null, "V030","VV061",newlist.get(0).getVv061(), "FV050", FV050, "FN100",listSelected.get(i).getPn100(), getLogin().getUserName());
                        }
                    }else{
                         int count1 = store.update2ColumnTAB(null, "V030","VV061","", "FV050", FV050, "FN100",listSelected.get(i).getPn100(), getLogin().getUserName());
                    }
                  //  int count = store.update2ColumnTAB(null, "V030","FN100C",String.valueOf(pn100), "FV050", FV050, "FN100",listSelected.get(i).getPn100(), getLogin().getUserName());
                }
                listSelected.clear();
            }
        } catch (Exception e) {
        }
    }

    /**
     * @return the numberphong
     */
    public int getNumberphong() {
        return numberphong;
    }

    /**
     * @param numberphong the numberphong to set
     */
    public void setNumberphong(int numberphong) {
        this.numberphong = numberphong;
    }

    /**
     * @return the listV030Check
     */
    public List<N100> getListV030Check() {
        return listV030Check;
    }

    /**
     * @param listV030Check the listV030Check to set
     */
    public void setListV030Check(List<N100> listV030Check) {
        this.listV030Check = listV030Check;
    }

    /**
     * @return the listV030CheckLP
     */
    public List<N100> getListV030CheckLP() {
        return listV030CheckLP;
    }

    /**
     * @param listV030CheckLP the listV030CheckLP to set
     */
    public void setListV030CheckLP(List<N100> listV030CheckLP) {
        this.listV030CheckLP = listV030CheckLP;
    }

    /**
     * @return the listngayTour
     */
    public List<V050> getListngayTour() {
        return listngayTour;
    }

    /**
     * @param listngayTour the listngayTour to set
     */
    public void setListngayTour(List<V050> listngayTour) {
        this.listngayTour = listngayTour;
    }

    /**
     * @return the tongsonguoi
     */
    public int getTongsonguoi() {
        return tongsonguoi;
    }

    /**
     * @param tongsonguoi the tongsonguoi to set
     */
    public void setTongsonguoi(int tongsonguoi) {
        this.tongsonguoi = tongsonguoi;
    }

    /**
     * @return the tongsophongDK
     */
    public int getTongsophongDK() {
        return tongsophongDK;
    }

    /**
     * @param tongsophongDK the tongsophongDK to set
     */
    public void setTongsophongDK(int tongsophongDK) {
        this.tongsophongDK = tongsophongDK;
    }

    /**
     * @return the tongsonguoiCP
     */
    public int getTongsonguoiCP() {
        return tongsonguoiCP;
    }

    /**
     * @param tongsonguoiCP the tongsonguoiCP to set
     */
    public void setTongsonguoiCP(int tongsonguoiCP) {
        this.tongsonguoiCP = tongsonguoiCP;
    }

    /**
     * @return the tongsonguoiKP
     */
    public int getTongsonguoiKP() {
        return tongsonguoiKP;
    }

    /**
     * @param tongsonguoiKP the tongsonguoiKP to set
     */
    public void setTongsonguoiKP(int tongsonguoiKP) {
        this.tongsonguoiKP = tongsonguoiKP;
    }

    /**
     * @return the listallphong
     */
    public List<N100> getListallphong() {
        return listallphong;
    }

    /**
     * @param listallphong the listallphong to set
     */
    public void setListallphong(List<N100> listallphong) {
        this.listallphong = listallphong;
    }

    /**
     * @return the longdate
     */
    public long getLongdate() {
        return longdate;
    }

    /**
     * @param longdate the longdate to set
     */
    public void setLongdate(long longdate) {
        this.longdate = longdate;
    }

    /**
     * @return the ngaybatdau
     */
    public Date getNgaybatdau() {
        return ngaybatdau;
    }

    /**
     * @param ngaybatdau the ngaybatdau to set
     */
    public void setNgaybatdau(Date ngaybatdau) {
        this.ngaybatdau = ngaybatdau;
    }

    /**
     * @return the ngayketthuc
     */
    public Date getNgayketthuc() {
        return ngayketthuc;
    }

    /**
     * @param ngayketthuc the ngayketthuc to set
     */
    public void setNgayketthuc(Date ngayketthuc) {
        this.ngayketthuc = ngayketthuc;
    }

    /**
     * @return the listngay
     */
    public List<Integer> getListngay() {
        return listngay;
    }

    /**
     * @param listngay the listngay to set
     */
    public void setListngay(List<Integer> listngay) {
        this.listngay = listngay;
    }
    
}
